<%@page pageEncoding="utf-8" contentType="text/html; charset=utf-8" %>
<%@ include file="/admin/include/init_admin.jsp" %>
<%@ page import="com.welfare.admin.call.*" %>
<%

	
	String customer_id		= StringUtil.nvl(request.getParameter("customer_id"));



	HashMap infos = new HashMap();
	infos.put("customer_id",	customer_id);
	infos.put("sort_col", 		"counsel_date||counsel_id");
	infos.put("sort_asc", 		"desc");


	CallDAO dao 		= new CallDAO();
	HashList info		= dao.selectCustomerInfo(infos);	
	HashList list 		= dao.selectCounselList(infos);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
	<title><%= SYSTEM_NAME %></title>
	<%@ include file="/admin/include/cssnjs.jsp"  %>

	<script type="text/javascript">
	
	
	$(document).ready(function() {
		$('#list').find('tr').hover(
				function () { $(this).addClass("hover"); }
			  , function () { $(this).removeClass("hover"); }
			)
			.click(function(){
				var counselId = $(this).attr('counsel_id');
				cfOpen('/admin/call/counselInfo.jsp?counsel_id=' + counselId, 'counsel'+$.trim(counselId), 840, 640);
			});
	});
	

	function fnDelete() {
		if (confirm(MSG_D)) {
			$.ajax({
				url: './customerSave.do',
				type: "POST",
			    dataType: 'json',//html,text,json
			    data: $('#saveForm').serialize(),
			    error: function(data, status, err){
			    	alert(err);
			    },
				success: function(data){
					self.close();
					opener.fnSearch(1);
			    }
			});
		}
	}


	</script>
</head>
<body>
<div id="wrap">
		<div id="popup">
			<div class="menu_title">
				<h1>고객정보</h1>
				<div class="r mt2">
			<%	if (isAdmin) { %>
					<a href="./customerUpdate.jsp?customer_id=<%=customer_id%>"><img src="../images/btn_update.gif" /></a>
					<a href="#nohref" onclick="fnDelete()"><img src="../images/btn_delete.gif" /></a>
			<%	} %>
					<input type="image" class="button" src="../images/btn_close.gif" onclick="self.close()"/>
				</div>
			</div>
			<div class="clear line_01"></div>

			<form name="saveForm" id="saveForm" method="post" action="">
				<input type="hidden" name="job_type" id="job_type" value="D"/>
				<input type="hidden" name="customer_id" value="<%=customer_id %>"/>
			</form>

			<table cellpadding="0" cellspacing="0" class="table_01 mt5">
			<colgroup>
				<col width="80px"/>
				<col/>
				<col width="80px"/>
				<col/>
				<col width="80px"/>
				<col/>
			</colgroup>
			<tbody>
				<tr>
					<th><p>이름</p></th>
					<td>
						<%= info.get("customer_name", 0) %>
					</td>
					<th><p>생년월일</p></th>
					<td>
						<%= info.get("birth_date", 0) %>
					</td>
					<th><p>성별</p></th>
					<td>
						<%= info.get("gender_name", 0) %>
					</td>
				</tr>
				<tr>
					<th><p>세대구분</p></th>
					<td>
						<%= info.get("family_gubn_name", 0) %>
					</td>
					<th><p>가구원수</p></th>
					<td>	
						<%= info.get("family_count", 0) %>
					</td>
					<th><p>보장구분</p></th>
					<td>
						<%= info.get("support_gubn_name", 0) %>
					</td>
				</tr>
				<tr>
					<th><p>전화번호</p></th>
					<td>
						<%= info.get("tel_no", 0) %>
					</td>
					<th><p>핸드폰번호</p></th>
					<td>
						<%= info.get("hp_no", 0) %>
					</td>
					<th><p>수신동의</p></th>
					<td>
						<%= "Y".equals(info.get("tel_agree_yn", 0)) ? "전화(O)" : "전화(X)" %>, 
						<%= "Y".equals(info.get("sms_agree_yn", 0)) ? "SMS(O)" : "SMS(X)" %>
					</td>
				</tr>
				<tr>
					<th><p>행정동</p></th>
					<td>
						<%= info.get("dong_name", 0) %>
					</td>
					<th><p>주소</p></th>
					<td colspan="3">
						<%= info.get("address", 0) %>
					</td>
				</tr>
				<tr>
					<th><p>비고</p></th>
					<td colspan="5">
						<%= info.getToBr("remarks", 0) %>
					</td>
				</tr>
				<tr>
					<th><p>등록자</p></th>
					<td>
						<%= info.get("reg_user", 0) %>
					</td>
					<th><p>등록일</p></th>
					<td colspan="3">
						<%= info.getDate("reg_date", 0) %>
					</td>
				</tr>
			</tbody>
			</table>
			
			<h3>상담이력</h3>
			
			<table width="100%" cellpadding="0" cellspacing="0" class="mt5">
						<colgroup>
								<col width="40px"/>
								<col width="80px"/>
								<col width="60px"/>
								<col width="90px"/>
								<col width="90px"/>
								<col width="90px"/>
								<col />
						</colgroup>
						<thead>
							<tr> 
								<th><p>경로</p></th>
								<th><p>상담일자</p></th>
								<th><p>상담원</p></th>
								<th><p>분류a</p></th>
								<th><p>분류b</p></th> 
								<th><p>분류c</p></th> 
								<th><p>서비스명</p></th>  
							</tr>
						</thead>
						<tbody id="list">
			<%	for (int i = 0; i < list.size(); i++) { %>
						<tr height="26px;" counsel_id="<%= list.get("counsel_id",i) %>"> 
							<td class="c blx"><%= list.get("counsel_path",i) %></td>
							<td class="c"><%= StringUtil.toDate(list.get("counsel_date",i),".") %></td>
							<td class="c"><%= list.get("counseller",i) %></td>
							<td><%= list.get("counsel_kind1",i) %></td>
							<td><%= list.get("counsel_kind2",i) %></td>
							<td><%= list.get("counsel_kind3",i) %></td>
							<td><%= list.get("service_name",i) %></td>
						</tr>
				<%
					}
				%>
						</tbody>
						</table>
						
		</div>
		
</div>



</body>
</html>
